package io.renren.modules.admin.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.admin.entity.BrandActivityEntity;
import io.renren.modules.admin.service.BrandActivityService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 品牌活动
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-01-06 16:04:02
 */
@RestController
@RequestMapping("admin/brandactivity")
public class BrandActivityController {
    @Autowired
    private BrandActivityService brandActivityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("admin:brandactivity:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = brandActivityService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{brandActivityId}")
    @RequiresPermissions("admin:brandactivity:info")
    public R info(@PathVariable("brandActivityId") Integer brandActivityId){
		BrandActivityEntity brandActivity = brandActivityService.getById(brandActivityId);

        return R.ok().put("brandActivity", brandActivity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("admin:brandactivity:save")
    public R save(@RequestBody BrandActivityEntity brandActivity){
		brandActivityService.save(brandActivity);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("admin:brandactivity:update")
    public R update(@RequestBody BrandActivityEntity brandActivity){
		brandActivityService.updateById(brandActivity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("admin:brandactivity:delete")
    public R delete(@RequestBody Integer[] brandActivityIds){
		brandActivityService.removeByIds(Arrays.asList(brandActivityIds));

        return R.ok();
    }

}
